home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc Source Code / Utilities / Interfaces / PasclStr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-22  |  3.0 KB  |  118 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        PasclStr.h
  3.  
  4.     Contains:    Pascal string manipulation routines
  5.  
  6.     Owned by:    Nick Pilch
  7.  
  8.     Copyright:    © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     
  11. */
  12.  
  13. #ifndef _PASCLSTR_
  14. #define _PASCLSTR_
  15.  
  16. #ifndef _ODTYPES_
  17. #include "ODTypes.h"
  18. #endif
  19.  
  20. #ifdef THINK_CPLUS
  21.     #ifndef __pascal__
  22.     #include <pascal.h>
  23.     #endif
  24. #else // THINK_CPLUS
  25.     #ifndef __STRINGS__
  26.     #include <strings.h>
  27.     #endif
  28. #endif // THINK_CPLUS
  29.  
  30. #ifndef __TYPES__
  31. #include <types.h>
  32. #endif
  33.  
  34. #ifndef _ITEXT_
  35. #include <IText.h>
  36. #endif
  37.  
  38.  
  39. #ifdef __cplusplus
  40.     // These routines convert the string in place.
  41.     
  42.     inline StringPtr CToPascalString(char* string)
  43.     {
  44.         return c2pstr(string);
  45.     }
  46.     
  47.     inline char* PascalToCString(StringPtr string)
  48.     {
  49.         return p2cstr(string);
  50.     }
  51.  
  52.     extern "C" {
  53.  
  54. #else
  55.     #define CToPascalString    c2pstr
  56.     #define PascalToCString p2cstr
  57. #endif
  58.  
  59.  
  60. #ifdef _OD_IMPL_SHARE_UTILS_
  61. #pragma import on
  62. #endif
  63.  
  64. void ConcatPascalStrings(Str255 destString, ConstStr255Param srcString);
  65.     // Error checking is done to ensure that the limit of 256 chars is not
  66.     //    exceeded.
  67.  
  68. void CopyPascalString(Str255 destString, ConstStr255Param srcString);
  69.  
  70. ODBoolean EqualPascalStrings(ConstStr255Param str1, ConstStr255Param str2);
  71.     // Returns kODTrue if strings are equal, kODFalse otherwise. Does a CASE-
  72.     //    INSENSITIVE compare!
  73.  
  74. void CopyISOStr2PStr(Str255 destString, const ODISOStr srcString);
  75.  
  76. StringPtr IntlToPStr(ODIText* intlText, StringPtr pstr);
  77.     // Caller must allocate storage for pstr. No error checking is done for
  78.     //    strings longer than 255 chars. Simply grabs the text from the theText
  79.     //    field of ODIText.
  80.     //    CAUTION: This function is only intended to convert the bytes of the
  81.     //    IText to a pascal string. These bytes are not valid without the
  82.     //    accompanying script code and language code as well.
  83.  
  84. ODIText* PStrToIntl(StringPtr pstr, ODIText** intlText);
  85.     // Caller must dispose storage for intlText when done with it. The ODIText
  86.     //    is created with theScriptCode = smScriptRoman and
  87.     //    theLangCode = langEnglish.  Storage for the ODIText is allocated only if
  88.     //  intlText == NULL; otherwise it's assumed that *intlText is a valid ptr to
  89.     //  an ODIText big enough to hold the string.
  90.     //    CAUTION: This function is only intended to convert the bytes of the
  91.     //    pascl string to the bytes in an ODIText. These bytes are not valid
  92.     //    without first setting the appropriate accompanying script code and
  93.     //    language code in the ODIText as well.
  94.  
  95. ODHandle PStrToText(ConstStr255Param pstr);
  96.     // Caller must dispose of the returned ODHandle.
  97.  
  98. void TextToPStr(ODHandle textHandle, Str255 destString);
  99.  
  100. ODSShort ClipStringToBytes( Str255 string, ODSShort numBytes,
  101.         ODScriptCode scriptCode );
  102.     // Truncate a pascal string so that it occupies the given number of bytes
  103.     // (plus the length byte) or one less.  The one less case occurs when
  104.     // simple truncation would clip off the second byte of a double-byte
  105.     // character.
  106.     // returns the number of bytes the truncated string is long, ie numBytes or
  107.     // numBytes - 1.
  108.  
  109. #ifdef __cplusplus
  110. }
  111. #endif
  112.  
  113. #ifdef _OD_IMPL_SHARE_UTILS_
  114. #pragma import off
  115. #endif
  116.  
  117.  
  118. #endif // _PASCLSTR_